package designMode.trategy;

public class Test2 {
    public static void main(String[] args) {
        Human me = new Human();
        me.show();
        me.eat();
        me.fly();
        Bird sparrow = new Bird();
        sparrow.show();
        sparrow.eat();
        sparrow.fly();
        QingWa xiaolv = new QingWa();
        xiaolv.show();
        xiaolv.eat();
        xiaolv.fly();
    }
}

abstract class Animal {
    AnimalFly fly;
    AnimalEat eat;

    Animal() {
    }

    void fly() {
        fly.doFly();
    }

    void eat() {
        eat.doEat();
    }

}

interface AnimalFly {
    void doFly();
}

interface AnimalEat {
    void doEat();
}

class FlyByings implements AnimalFly {
    @Override
    public void doFly() {
        System.out.println("�����ó��ɣ�");
    }
}

class FlyByNo implements AnimalFly {
    @Override
    public void doFly() {
        System.out.println("�Ҳ���ɡ���");
    }
}

class EatBug implements AnimalEat {
    @Override
    public void doEat() {
        System.out.println("�ҳԳ��ӡ�");
    }
}

class EatAny implements AnimalEat {
    @Override
    public void doEat() {
        System.out.println("��ɶҲ�ԡ�");
    }
}

class Human extends Animal {
    Human() {
        super();
        fly = new FlyByNo();
        eat = new EatAny();
    }

    void show() {
        System.out.println("�������ࡣ");
    }
}

class Bird extends Animal {
    Bird() {
        super();
        fly = new FlyByings();
        eat = new EatBug();
    }

    void show() {
        System.out.println("�������ࡣ");
    }
}

class QingWa extends Animal {
    QingWa() {
        super();
        fly = new FlyByNo();
        eat = new EatBug();
    }

    void show() {
        System.out.println("�������ܡ�");
    }
}
